#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :demo_jd_menu.py
# @Time      :2021/7/28 11:17
# @author    :Harry
'''
@case: 选择京东首页类目中第三列中第二个分类
@step:
1、访问京东首页；
2、点击类目中第三列第二个菜单【电脑】；
3、关闭退出浏览器；
'''
import time
from selenium import webdriver
from selenium.webdriver import ActionChains

driver = webdriver.Chrome()
driver.maximize_window()

driver.get('https://www.jd.com')
time.sleep(5)
# 操作
# driver.find_element_by_css_selector('a[href="//bg.jd.com"]').click()

# driver.find_element_by_css_selector('div[id="J_cate"] > ul > li:nth-child(3) > a:nth-child(1)').click()
# driver.find_element_by_css_selector('#J_cate > ul > li:nth-child(3) > a:nth-child(3)').click()

# driver.find_element_by_xpath('//a[@href="//bg.jd.com"]').click()

# driver.find_element_by_xpath('//div[@id="J_cate"]/ul/li[3]/a[2]').click()

# driver.find_element_by_xpath('//a[text()="办公"]').click()
# 鼠标悬浮
diannao = driver.find_element_by_xpath('//a[contains(@href, "diannao")]')
ac = ActionChains(driver)
ac.move_to_element(diannao).perform()
time.sleep(2)
driver.find_element_by_xpath('//div[@id="cate_item3"]/div[1]/div[2]/dl[5]/dd/a[1]').click()


time.sleep(3)
driver.quit()